<style>
    .layui-btn{
        padding: 0 7px !important;
    }
    .layui-laypage a, .layui-laypage span{
        background-color: #f2f2f2;
    }
</style>

<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>
<script type="text/html" id="caozuo">
    {{# if (!d.theme_admin) {  }}
    <input type="submit"  value="配置中文桌面"     class="layui-btn " lay-submit="" lay-event="updateTheme"/>
    {{#  }  }}

    {{# if (!d.theme_admin) {  }}
    <input type="submit"  value="配置英文桌面"     class="layui-btn " lay-submit="" lay-event="updateEnglishTheme"/>
    {{#  }  }}

</script>

<div class="layui-form-item layui-col-xs12 site-demo-button" id="layerDemo" style="margin-left: 2%;">
    <!--<button type="submit" class="layui-btn " lay-submit="" lay-filter="addTheme" data-method="setTop">-->
        <!--<span class="glyphicon glyphicon-plus"></span >新增主题</button>-->
</div>

<script type="text/html" id="tol">

    <div>
        <div style="float:left;">主题管理</div>
        <div style="float:right;margin-right: 50px">共有数据：<span id="count"></span>条</div>
    </div>

</script>
<div class="layui-form">

    <table class="layui-table" id="themedata" lay-filter="themedata"></table>

    <div id="demo7" style="text-align: center"></div>
</div>

<!--</div>-->
<script>

    var local_store = layui.data("local_store");
    var local = local_store.token;
    $.ajax({
        type:"get",
        url:"/admin/station/query/stationLoginQuanxXian?stationId="+json.id,
        dataType: "json",
        contentType:"application/json;charset=utf-8",
        // beforeSend: function(request) {
        //     request.setRequestHeader("token", local);
        // },
        success:function (res) {
            if(res.code==500){
                alert("权限不足")
                location="../../admin/main.html";
                return
            }}})
    var pages= localStorage.getItem('page');

    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        var table = layui.table;

        table.render({
            elem: "#themedata",
            url: "/admin/theme/query/themeAll?station_id="+json.id,
            id: "t",
            // type:'get',
            toolbar:"#tol",
            cols: [[{
                title: "编号",
                field: "theme_id",
                width: "7%",
                align: "center"
            },
                {
                    title: "主题名称",
                    field: "theme_name",
                    width: "27%",
                    align: "center"
                }
                ,   {
                    title: "主题图片",
                    field: "theme_image",
                    width: "17%",
                    align: "center",
                    templet: function(d) {
                        return "<img width='50px' height='50px' src='" + IMAGE_SERVER +"/" + d.theme_image + "'></img>";
                    }
                }
                ,
                {
                    title: "审核状态",
                    field: "theme_status",
                    width: "17%",
                    align: "center"
                },
                {
                    title: "操作",
                    width: "30%",
                    align: "center",
                    toolbar: "#caozuo"
                }
            ]],page:true,
            limit:40,
            done: function(res, curr, count){
                localStorage.setItem('page',curr);
                $("#count").html(count);
            }
        })

        table.on("tool(themedata)", function (obj) {
            var getdata = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
            switch (layEvent) {
                case "updateTheme":
                    location="/screen?id="+getdata.theme_id+"&station_id="+json.id+"&type=2&language=CN";
                    break;
                case "updateEnglishTheme":
                    location="/screen?id="+getdata.theme_id+"&station_id="+json.id+"&type=2&language=EN";
                    break;

            }
        });

        form.on('submit(addTheme)',function () {

            location="#/layui/addtheme";
            location.reload();
        })
    });

    function GetRequest() {
        var url = decodeURI(location.search); //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }

    var json=GetRequest();

</script>

<!--分页-->
<script>
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;

    });
</script>

